package reflect.web.project02;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;

public class Solve {
    String name = "张三";
    int age = 18;
    long id = 14522589L;
    void giveParams() throws Exception {
        Entity entity = new Entity();
        Class<Entity> entityClass = Entity.class;
        Method method = entityClass.getMethods()[0];
        Parameter parameter = method.getParameters()[0];
        Class<?> type = parameter.getType();
        if(type==String.class){
            method.invoke(entity,name);
        }else if(type==int.class){
            method.invoke(entity,age);
        }else{
            method.invoke(entity,id);
        }
    }
}
